﻿using System;

namespace Coogle.Core
{
    public class Shipping
    {
        private readonly ShippingType m_type;
        private readonly Int32 m_seal;
        private readonly Int32 m_weight;
        private readonly String m_port;
        private readonly String m_ship;
        private readonly DateTime m_date;
        private readonly String m_forwarder;

        public ShippingType Type
        {
            get { return m_type; }
        }

        public Int32 Seal
        {
            get { return m_seal; }
        }

        public Int32 Weight
        {
            get { return m_weight; }
        }

        public String Port
        {
            get { return m_port; }
        }

        public String Ship
        {
            get { return m_ship; }
        }

        public DateTime Date
        {
            get { return m_date; }
        }

        public String Forwarder
        {
            get { return m_forwarder; }
        }

        public Shipping(String type, Int32 seal, Int32 weight, String fromPort, String toPort, String ship, DateTime? boardingDate, DateTime? landingDate, String forwarder)
        {
            m_type = new ShippingType(type);
            m_seal = seal;
            m_weight = weight;
            m_port = type == "E" ? toPort : fromPort;
            m_ship = ship;
            m_date = type == "E" ? boardingDate.GetValueOrDefault() : landingDate.GetValueOrDefault();
            m_forwarder = forwarder;
        }
    }
}
